/**
 * EmployeeEntityHandlerBean.java
 * 
 */

package com.example.managedbeans;



import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import com.example.service.*;
import com.example.entities.*;





public class EmployeeEntityHandlerBean
{
  private String employeeFirstName;
  private String employeeLastName;
  private String employeePhoneNumber;
  private  List<Employee> employeeList;


public EmployeeEntityHandlerBean()
{
	
}
    	


	public String getEmployeeFirstName() {
	return employeeFirstName;
}



public void setEmployeeFirstName(String employeeFirstName) {
	this.employeeFirstName = employeeFirstName;
}



public String getEmployeeLastName() {
	return employeeLastName;
}



public void setEmployeeLastName(String employeeLastName) {
	this.employeeLastName = employeeLastName;
}



public String getEmployeePhoneNumber() {
	return employeePhoneNumber;
}



public void setEmployeePhoneNumber(String employeePhoneNumber) {
	this.employeePhoneNumber = employeePhoneNumber;
}



public List<Employee> getEmployeeList() {
	return employeeList;
}



	public String insertNewEmployee()
    {   
		
    	Employee employee = new Employee();
    	employee.setFirstName(this.employeeFirstName);
    	employee.setLastName(this.employeeLastName);
    	employee.setPhoneNumber(this.employeePhoneNumber);
    	EmployeeHandler ph = new EmployeeHandler();
    	ph.create(employee);
    	return "viewid?faces-redirect=true";
    }
	
	public String getAllEmployees()
	{
		EmployeeHandler ph = new EmployeeHandler();
		employeeList = ph.getAllEmployees();
		return "true";		
	}
	
	public String delete()
	{
		EmployeeHandler ph = new EmployeeHandler();
		ph.deleteByEmployeeLastName(this.employeeLastName);
		return "true";
	}
	public String test()
	{
		System.out.println("Test");
		return "failure";
	}
    
 
}
